package net.hn.hnms.biz.project.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.project.request.CheckRecordReq;
import net.hn.hnms.biz.project.service.ICheckRecordService;
import net.hn.hnms.biz.project.vo.CheckRecordVo;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.log.annotation.Log;
import net.hn.hnms.sys.common.log.enums.BusinessType;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "检查记录", tags = {"质量管理"})
@RestController
@RequestMapping("/qualityManagement/checkRecord")
public class CheckRecordController {

    @Autowired
    private ICheckRecordService checkRecordService;

    /**
     * 新增检查记录
     */
    @ApiOperation("新增检查记录")
    @PostMapping("/add")
    @AutoSetMineCode
    @Log(title = "新增检查记录", businessType = BusinessType.INSERT)
    public R<Void> add(@RequestBody CheckRecordReq req) {
        return checkRecordService.insertReq(req);
    }
    /**
     *
     * 删除检查记录
     */
    @ApiOperation("删除检查记录")
//    @SaCheckPermission("check:record:delete")
    @ApiImplicitParam(name = "idList", value = "要删除的id值,用逗号间隔", required = true, allowMultiple = true, dataType = "String", paramType = "query")
    @DeleteMapping("delete")
    @Log(title = "删除检查记录", businessType = BusinessType.DELETE)
    public R<Void> delete(@RequestParam("idList") List<String> idList) {
        return checkRecordService.deleteList(idList);
    }

    /**
     *
     * 修改检查记录
     */
    @ApiOperation("修改检查记录")
//    @SaCheckPermission("check:record:update")
    @PostMapping("/update")
    @Log(title = "修改检查记录", businessType = BusinessType.UPDATE)
    public R<Void> update(@RequestBody CheckRecordReq req) {
        return checkRecordService.updateReq(req);
    }
    /**
     *
     * 修改检查记录
     */
    @ApiOperation("查询检查记录")
    @PostMapping("/selectPageList")
    @AutoSetMineCode
    @Log(title = "查询检查记录", businessType = BusinessType.UPDATE)
    public R<ResponsePage<List<CheckRecordVo>>> selectPageList(@RequestBody CheckRecordReq req, PageQuery pageQuery) {
        return checkRecordService.selectPageList(req,pageQuery);
    }
}
